//提供一个构造函数
function TextCircle(option) {
    //初始化操作
    this._init(option)
}
//设置原型对象
TextCircle.prototype = {
    //修正构造器属性
    constructor:TextCircle,
    //初始化方法
    _init:function (option) {
        option = option || {};
        this.x = option.x || 0;
        this.y = option.y || 0;
        this.outerRadius = option.outerRadius || 0;
        this.innerRadius = option.innerRadius || 0;

        this.innerFill = option.innerFill || 'black';
        this.outerColor = option.outerColor || 'black';

        this.text = option.text || 'XXX';
        this.textColor = option.textColor || 'white';
    },
    render:function (layerOrGroup) {
        var group = new Konva.Group({
            x:this.x,
            y:this.y
        });
        layerOrGroup.add(group);

        //创建内圆
        var innerCircle = new Konva.Circle({
            //创建内圆,直接指向这个圆的innerRadius
            radius: this.innerRadius,
            fill: this.innerFill
        });
        group.add(innerCircle);

        //圆环的制作
        var ring = new Konva.Ring({
            innerRadius: this.innerRadius,
            outerRadius: this.outerRadius,
            fill: this.outerColor
        });
        group.add(ring);

        //创建文字
        var text = new Konva.Text({
            x: -this.innerRadius,
            y: -8,
            width: 2 * this.innerRadius,
            text: this.text,
            fontSize: 16,
            fill: this.textColor,
            align: "center"
        });
        group.add(text);
    }
};